Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More ā†’
Socket
Sign inDemoInstall
Socket

@inquirer/prompts

Package Overview
Dependencies
Maintainers
3
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inquirer/prompts

Inquirer prompts, combined in a single package

  • 7.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4M
increased by1.57%
Maintainers
3
Weekly downloads
Ā 
Created

What is @inquirer/prompts?

@inquirer/prompts is a collection of prompt modules for the Inquirer.js library, which is used to create interactive command-line interfaces. It provides a variety of prompt types to gather user input in a structured and user-friendly manner.

What are @inquirer/prompts's main functionalities?

Text Prompt

The text prompt allows you to ask the user for a simple text input. In this example, the user is asked for their name, and the input is then printed to the console.

const { text } = require('@inquirer/prompts');

(async () => {
  const answer = await text({ message: 'What is your name?' });
  console.log(`Hello, ${answer}!`);
})();

Password Prompt

The password prompt is used to securely gather password input from the user. The input is masked to ensure privacy.

const { password } = require('@inquirer/prompts');

(async () => {
  const answer = await password({ message: 'Enter your password:' });
  console.log('Password received');
})();

Confirm Prompt

The confirm prompt asks the user a yes/no question. The response is a boolean value indicating the user's choice.

const { confirm } = require('@inquirer/prompts');

(async () => {
  const answer = await confirm({ message: 'Do you want to continue?' });
  console.log(`User response: ${answer}`);
})();

List Prompt

The list prompt presents a list of options to the user, allowing them to select one. The selected option is then returned.

const { list } = require('@inquirer/prompts');

(async () => {
  const answer = await list({ message: 'Choose a color:', choices: ['Red', 'Green', 'Blue'] });
  console.log(`You chose: ${answer}`);
})();

Checkbox Prompt

The checkbox prompt allows the user to select multiple options from a list. The selected options are returned as an array.

const { checkbox } = require('@inquirer/prompts');

(async () => {
  const answer = await checkbox({ message: 'Select toppings:', choices: ['Pepperoni', 'Cheese', 'Mushrooms'] });
  console.log(`You selected: ${answer.join(', ')}`);
})();

Other packages similar to @inquirer/prompts

Keywords

FAQs

Package last updated on 20 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc